local Luashengwei = fk.CreateSkill {
  name = "Luashengwei",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
  ["Luashengwei"] = "圣威",
  ["@shengwei-turn"] = "圣威",
  ["@@lua_louyi"] = "蝼蚁",
  [":Luashengwei"] = "锁定技，除你外所有角色于回合内出牌次数超过7张时你结束其回合" ..
  "<br>你造成的伤害结算开始前，令目标获得“蝼蚁”标记直到本次伤害结算结束，有“蝼蚁”标记的角色发动技能时取消之，且你对其造成的伤害至少为其体力上限。",
  ["$Luashengwei1"] = "四圣汇诛仙，分辩忠与奸。",
}

Luashengwei:addEffect(fk.CardUseFinished, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(Luashengwei.name) and target and target ~= player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(target, "@shengwei-turn", 1)
    if target:getMark("@shengwei-turn") >= 7 then
      room:endTurn()
    end
  end,
})

Luashengwei:addEffect(fk.PreDamage, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return data.from and data.from == player and player:hasSkill(Luashengwei.name) and data.to ~= player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(data.to, "@@lua_louyi", 1)
    data.damage = math.max(data.damage, data.to.maxHp)
  end,
})

Luashengwei:addEffect(fk.DamageFinished, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(Luashengwei.name, true, true) and data.to:getMark("@@lua_louyi") == 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(data.to, "@@lua_louyi", 0)
  end,
})

Luashengwei:addEffect(fk.SkillEffect, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target and player:hasSkill(Luashengwei.name, true, true) and target:getMark("@@lua_louyi") == 1 and data.skill:isPlayerSkill(target)
    and target:hasSkill(data.skill:getSkeleton().name, true, true)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local e = room.logic:getCurrentEvent():findParent(GameEvent.SkillEffect)
    if e then
      e:shutdown()
    end
  end,
})


return Luashengwei
